package com.melesta.engine;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

public class EngineTextInputWraper
  implements TextWatcher, TextView.OnEditorActionListener
{
  private static final String TAG = EngineTextInputWraper.class.getSimpleName();
  private final EngineGLSurfaceView mCocos2dxGLSurfaceView;
  private String mOriginText;
  private String mText;

  public EngineTextInputWraper(EngineGLSurfaceView paramEngineGLSurfaceView)
  {
    this.mCocos2dxGLSurfaceView = paramEngineGLSurfaceView;
  }

  private boolean isFullScreenEdit()
  {
    return ((InputMethodManager)this.mCocos2dxGLSurfaceView.getCocos2dxEditText().getContext().getSystemService("input_method")).isFullscreenMode();
  }

  public void afterTextChanged(Editable paramEditable)
  {
    if (isFullScreenEdit())
      return;
    int i = paramEditable.length() - this.mText.length();
    if (i > 0)
    {
      String str = paramEditable.subSequence(this.mText.length(), paramEditable.length()).toString();
      this.mCocos2dxGLSurfaceView.insertText(str);
    }
    while (true)
    {
      this.mText = paramEditable.toString();
      return;
      while (i < 0)
      {
        this.mCocos2dxGLSurfaceView.deleteBackward();
        i++;
      }
    }
  }

  public void beforeTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3)
  {
    this.mText = paramCharSequence.toString();
  }

  public boolean onEditorAction(TextView paramTextView, int paramInt, KeyEvent paramKeyEvent)
  {
    if ((this.mCocos2dxGLSurfaceView.getCocos2dxEditText() == paramTextView) && (isFullScreenEdit()))
    {
      for (int i = this.mOriginText.length(); i > 0; i--)
        this.mCocos2dxGLSurfaceView.deleteBackward();
      String str1 = paramTextView.getText().toString();
      if (str1.compareTo("") == 0)
        str1 = "\n";
      if ('\n' != str1.charAt(-1 + str1.length()))
        str1 = str1 + '\n';
      String str2 = str1;
      this.mCocos2dxGLSurfaceView.insertText(str2);
    }
    if (paramInt == 6)
      this.mCocos2dxGLSurfaceView.requestFocus();
    return false;
  }

  public void onTextChanged(CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3)
  {
  }

  public void setOriginText(String paramString)
  {
    this.mOriginText = paramString;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.melesta.engine.EngineTextInputWraper
 * JD-Core Version:    0.6.2
 */